<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: drogon::Topic&lt; MessageType &gt; 模板类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacedrogon.html">drogon</a></li><li class="navelem"><a class="el" href="classdrogon_1_1Topic.html">Topic</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public 类型</a> &#124;
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="classdrogon_1_1Topic-members.html">所有成员列表</a>  </div>
  <div class="headertitle"><div class="title">drogon::Topic&lt; MessageType &gt; 模板类 参考</div></div>
</div><!--header-->
<div class="contents">

<p>This class template presents an unnamed topic.  
 <a href="classdrogon_1_1Topic.html#details">更多...</a></p>

<p><code>#include &lt;<a class="el" href="PubSubService_8h_source.html">PubSubService.h</a>&gt;</code></p>
<div class="dynheader">
类 drogon::Topic&lt; MessageType &gt; 继承关系图:</div>
<div class="dyncontent">
<div class="center"><img src="classdrogon_1_1Topic__inherit__graph.png" border="0" usemap="#adrogon_1_1Topic_3_01MessageType_01_4_inherit__map" alt="Inheritance graph"/></div>
<map name="adrogon_1_1Topic_3_01MessageType_01_4_inherit__map" id="adrogon_1_1Topic_3_01MessageType_01_4_inherit__map">
<area shape="rect" title="This class template presents an unnamed topic." alt="" coords="5,79,232,104"/>
<area shape="rect" title=" " alt="" coords="38,5,199,31"/>
<area shape="poly" title=" " alt="" coords="121,44,121,79,116,79,116,44"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">图例</a>]</span></center></div>
<div class="dynheader">
drogon::Topic&lt; MessageType &gt; 的协作图:</div>
<div class="dyncontent">
<div class="center"><img src="classdrogon_1_1Topic__coll__graph.png" border="0" usemap="#adrogon_1_1Topic_3_01MessageType_01_4_coll__map" alt="Collaboration graph"/></div>
<map name="adrogon_1_1Topic_3_01MessageType_01_4_coll__map" id="adrogon_1_1Topic_3_01MessageType_01_4_coll__map">
<area shape="rect" title="This class template presents an unnamed topic." alt="" coords="5,79,232,104"/>
<area shape="rect" title=" " alt="" coords="38,5,199,31"/>
<area shape="poly" title=" " alt="" coords="121,44,121,79,116,79,116,44"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">图例</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-types" name="pub-types"></a>
Public 类型</h2></td></tr>
<tr class="memitem:a803792904817c4cb758ee1b57ebdd7b2" id="r_a803792904817c4cb758ee1b57ebdd7b2"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">MessageHandler</a> = std::function&lt; void(const MessageType &amp;)&gt;</td></tr>
<tr class="separator:a803792904817c4cb758ee1b57ebdd7b2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab3f96c1355b779606f9adf322ae653aa" id="r_ab3f96c1355b779606f9adf322ae653aa"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1Topic.html#ab3f96c1355b779606f9adf322ae653aa">SharedMutex</a> = std::shared_timed_mutex</td></tr>
<tr class="separator:ab3f96c1355b779606f9adf322ae653aa"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:a64924c059baa1475f4640ed3593d7e3b" id="r_a64924c059baa1475f4640ed3593d7e3b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1Topic.html#a64924c059baa1475f4640ed3593d7e3b">publish</a> (const MessageType &amp;message) const</td></tr>
<tr class="memdesc:a64924c059baa1475f4640ed3593d7e3b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Publish a message, every subscriber in the topic will receive the message.  <br /></td></tr>
<tr class="separator:a64924c059baa1475f4640ed3593d7e3b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4b85d748b06aa39438ee90846e46bc2c" id="r_a4b85d748b06aa39438ee90846e46bc2c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1Topic.html#a4b85d748b06aa39438ee90846e46bc2c">subscribe</a> (const <a class="el" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">MessageHandler</a> &amp;handler)</td></tr>
<tr class="memdesc:a4b85d748b06aa39438ee90846e46bc2c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Subscribe to the topic.  <br /></td></tr>
<tr class="separator:a4b85d748b06aa39438ee90846e46bc2c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9b2d54de15b953cb98712c3ced46b0c5" id="r_a9b2d54de15b953cb98712c3ced46b0c5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1Topic.html#a9b2d54de15b953cb98712c3ced46b0c5">subscribe</a> (<a class="el" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">MessageHandler</a> &amp;&amp;handler)</td></tr>
<tr class="memdesc:a9b2d54de15b953cb98712c3ced46b0c5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Subscribe to the topic.  <br /></td></tr>
<tr class="separator:a9b2d54de15b953cb98712c3ced46b0c5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5a1f20d1a2e6b186fa16ea6f30589933" id="r_a5a1f20d1a2e6b186fa16ea6f30589933"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1Topic.html#a5a1f20d1a2e6b186fa16ea6f30589933">unsubscribe</a> (<a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> id)</td></tr>
<tr class="memdesc:a5a1f20d1a2e6b186fa16ea6f30589933"><td class="mdescLeft">&#160;</td><td class="mdescRight">Unsubscribe from the topic.  <br /></td></tr>
<tr class="separator:a5a1f20d1a2e6b186fa16ea6f30589933"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3a04d2de037c697b61176418aff5544b" id="r_a3a04d2de037c697b61176418aff5544b"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1Topic.html#a3a04d2de037c697b61176418aff5544b">empty</a> () const</td></tr>
<tr class="memdesc:a3a04d2de037c697b61176418aff5544b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check if the topic is empty.  <br /></td></tr>
<tr class="separator:a3a04d2de037c697b61176418aff5544b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a202a7f4f40b4437133cba1efdfad9407" id="r_a202a7f4f40b4437133cba1efdfad9407"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1Topic.html#a202a7f4f40b4437133cba1efdfad9407">clear</a> ()</td></tr>
<tr class="memdesc:a202a7f4f40b4437133cba1efdfad9407"><td class="mdescLeft">&#160;</td><td class="mdescRight">Remove all subscribers from the topic.  <br /></td></tr>
<tr class="separator:a202a7f4f40b4437133cba1efdfad9407"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><div class="compoundTemplParams">template&lt;typename MessageType&gt;<br />
class drogon::Topic&lt; MessageType &gt;</div><p>This class template presents an unnamed topic. </p>
<dl class="tparams"><dt>模板参数</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">MessageType</td><td></td></tr>
  </table>
  </dd>
</dl>
</div><h2 class="groupheader">成员类型定义说明</h2>
<a id="a803792904817c4cb758ee1b57ebdd7b2" name="a803792904817c4cb758ee1b57ebdd7b2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a803792904817c4cb758ee1b57ebdd7b2">&#9670;&#160;</a></span>MessageHandler</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">using <a class="el" href="classdrogon_1_1Topic.html">drogon::Topic</a>&lt; MessageType &gt;::MessageHandler =  std::function&lt;void(const MessageType &amp;)&gt;</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="ab3f96c1355b779606f9adf322ae653aa" name="ab3f96c1355b779606f9adf322ae653aa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab3f96c1355b779606f9adf322ae653aa">&#9670;&#160;</a></span>SharedMutex</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">using <a class="el" href="classdrogon_1_1Topic.html">drogon::Topic</a>&lt; MessageType &gt;::SharedMutex =  std::shared_timed_mutex</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">成员函数说明</h2>
<a id="a202a7f4f40b4437133cba1efdfad9407" name="a202a7f4f40b4437133cba1efdfad9407"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a202a7f4f40b4437133cba1efdfad9407">&#9670;&#160;</a></span>clear()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1Topic.html">drogon::Topic</a>&lt; MessageType &gt;::clear </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Remove all subscribers from the topic. </p>

</div>
</div>
<a id="a3a04d2de037c697b61176418aff5544b" name="a3a04d2de037c697b61176418aff5544b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3a04d2de037c697b61176418aff5544b">&#9670;&#160;</a></span>empty()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classdrogon_1_1Topic.html">drogon::Topic</a>&lt; MessageType &gt;::empty </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Check if the topic is empty. </p>
<dl class="section return"><dt>返回</dt><dd>true means there are no subscribers. </dd>
<dd>
false means there are subscribers in the topic. </dd></dl>

</div>
</div>
<a id="a64924c059baa1475f4640ed3593d7e3b" name="a64924c059baa1475f4640ed3593d7e3b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a64924c059baa1475f4640ed3593d7e3b">&#9670;&#160;</a></span>publish()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1Topic.html">drogon::Topic</a>&lt; MessageType &gt;::publish </td>
          <td>(</td>
          <td class="paramtype">const MessageType &amp;&#160;</td>
          <td class="paramname"><em>message</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Publish a message, every subscriber in the topic will receive the message. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">message</td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a4b85d748b06aa39438ee90846e46bc2c" name="a4b85d748b06aa39438ee90846e46bc2c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4b85d748b06aa39438ee90846e46bc2c">&#9670;&#160;</a></span>subscribe() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <a class="el" href="classdrogon_1_1Topic.html">drogon::Topic</a>&lt; MessageType &gt;::subscribe </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">MessageHandler</a> &amp;&#160;</td>
          <td class="paramname"><em>handler</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Subscribe to the topic. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">handler</td><td>is invoked when a message arrives. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>SubscriberID </dd></dl>

</div>
</div>
<a id="a9b2d54de15b953cb98712c3ced46b0c5" name="a9b2d54de15b953cb98712c3ced46b0c5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9b2d54de15b953cb98712c3ced46b0c5">&#9670;&#160;</a></span>subscribe() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <a class="el" href="classdrogon_1_1Topic.html">drogon::Topic</a>&lt; MessageType &gt;::subscribe </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">MessageHandler</a> &amp;&amp;&#160;</td>
          <td class="paramname"><em>handler</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Subscribe to the topic. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">handler</td><td>is invoked when a message arrives. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>SubscriberID </dd></dl>

</div>
</div>
<a id="a5a1f20d1a2e6b186fa16ea6f30589933" name="a5a1f20d1a2e6b186fa16ea6f30589933"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5a1f20d1a2e6b186fa16ea6f30589933">&#9670;&#160;</a></span>unsubscribe()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1Topic.html">drogon::Topic</a>&lt; MessageType &gt;::unsubscribe </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a>&#160;</td>
          <td class="paramname"><em>id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Unsubscribe from the topic. </p>

</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li><a class="el" href="PubSubService_8h_source.html">PubSubService.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>
